
<!DOCTYPE html>
<html lang="zh-CN" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>人物3渲2学习总结 - 浪子之心</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="Blog,"> 
    <meta name="description" content="MrChen Bolg,描边法线外扩法中文一般称为“法线外扩法”、“背面膨胀法”，日文资料中会称作「背面法」，它们指的是同一个技术
解决方式第一个Pass：正常打光和绘制第二个Pass：
Vertex Shader阶段将顶,"> 
    <meta name="author" content="Jack Chen"> 
    <link rel="alternative" href="atom.xml" title="浪子之心" type="application/atom+xml"> 
    <link rel="icon" href="/blog/img/favicon.png"> 
    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">

    
<link rel="stylesheet" href="/blog/css/diaspora.css">

<meta name="generator" content="Hexo 5.4.1"><link rel="stylesheet" href="/blog/css/prism.css" type="text/css"></head>

<body class="loading">
    <span id="config-title" style="display:none">浪子之心</span>
    <div id="loader"></div>
    <div id="single">
    <div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <a class="iconfont icon-home image-icon" href="javascript:;" data-url="https://mrchenlearnspace.github.io/blog"></a>
    <div title="播放/暂停" class="iconfont icon-play"></div>
    <h3 class="subtitle">人物3渲2学习总结</h3>
    <div class="social">
        <div>
            <div class="share">
                <a title="获取二维码" class="iconfont icon-scan" href="javascript:;"></a>
            </div>
            <div id="qr"></div>
        </div>
    </div>
    <div class="scrollbar"></div>
</div>

    <div class="section">
        <div class="article">
    <div class='main'>
        <h1 class="title">人物3渲2学习总结</h1>
        <div class="stuff">
            <span>五月 11, 2022</span>
            
  <ul class="post-tags-list" itemprop="keywords"><li class="post-tags-list-item"><a class="post-tags-list-link" href="/blog/tags/Shader/" rel="tag">Shader</a></li></ul>


        </div>
        <div class="content markdown">
            <h1 id="描边"><a href="#描边" class="headerlink" title="描边"></a>描边</h1><h2 id="法线外扩法"><a href="#法线外扩法" class="headerlink" title="法线外扩法"></a>法线外扩法</h2><p>中文一般称为“法线外扩法”、“背面膨胀法”，日文资料中会称作「背面法」，它们指的是同一个技术</p>
<h3 id="解决方式"><a href="#解决方式" class="headerlink" title="解决方式"></a>解决方式</h3><p>第一个Pass：正常打光和绘制<br>第二个Pass：</p>
<p>Vertex Shader阶段将顶点向顶点法线方向移动一定距离<br>Rasterization阶段将Cull Mode设置为Cull Front</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line">Pass</span><br><span class="line">&#123;</span><br><span class="line">Name <span class="string">&quot;OUTLINE&quot;</span></span><br><span class="line">Cull Front</span><br><span class="line">ZWrite On</span><br><span class="line">ColorMask RGB</span><br><span class="line">Blend SrcAlpha OneMinusSrcAlpha</span><br><span class="line">    CGPROGRAM</span><br><span class="line">    <span class="meta">#<span class="keyword">pragma</span> vertex vert</span></span><br><span class="line">    <span class="meta">#<span class="keyword">pragma</span> fragment frag</span></span><br><span class="line">    <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;UnityCG.cginc&quot;</span></span></span><br><span class="line">    <span class="keyword">struct</span> <span class="title class_">appdata</span> &#123;</span><br><span class="line">        float4 vertex : POSITION;</span><br><span class="line">        float3 normal : NORMAL;</span><br><span class="line">        float4 texCoord : TEXCOORD0;</span><br><span class="line">        float4 vertexColor : COLOR;</span><br><span class="line">    &#125;;</span><br><span class="line">    <span class="keyword">struct</span> <span class="title class_">v2f</span> &#123;</span><br><span class="line">      float4 pos : POSITION;</span><br><span class="line">      float4 color : COLOR;</span><br><span class="line">      float4 tex : TEXCOORD0;</span><br><span class="line">    &#125;;</span><br><span class="line">    sampler2D _MainTex;</span><br><span class="line">    <span class="type">float</span> _Outline;</span><br><span class="line">    float4 _OutlineColor;</span><br><span class="line">    <span class="function">v2f <span class="title">vert</span><span class="params">(appdata v)</span> </span>&#123;</span><br><span class="line">        <span class="comment">// just make a copy of incoming vertex data but scaled according to normal direction</span></span><br><span class="line">      v2f o;</span><br><span class="line">      o.pos = <span class="built_in">UnityObjectToClipPos</span>(v.vertex);</span><br><span class="line">        float3 norm = <span class="built_in">mul</span>((float3x3)UNITY_MATRIX_IT_MV, v.normal);</span><br><span class="line">        float2 offset = <span class="built_in">TransformViewToProjection</span>(norm.xy);</span><br><span class="line">       <span class="comment">// float2 offset = (norm.xy);</span></span><br><span class="line">      o.pos.xy += offset * _Outline*<span class="number">0.0001</span>;</span><br><span class="line">      o.tex = v.texCoord;</span><br><span class="line">      o.color = v.vertexColor;</span><br><span class="line">      <span class="keyword">return</span> o;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function">fixed4 <span class="title">frag</span> <span class="params">(v2f i)</span> : SV_Target</span></span><br><span class="line"><span class="function">    &#123;</span></span><br><span class="line">        half4 base_col = <span class="built_in">tex2D</span>(_MainTex,i.tex);</span><br><span class="line">        <span class="keyword">return</span> _OutlineColor*base_col;</span><br><span class="line">    &#125;</span><br><span class="line">    ENDCG</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="缺点"><a href="#缺点" class="headerlink" title="缺点"></a>缺点</h3><ol>
<li>描边出现断裂，或者出现了看起来很奇怪的描边<br><img src="https://img-blog.csdnimg.cn/15c86e7c8bef4fc4aa24ece0905fae53.png" alt="在这里插入图片描述"><br>解决方案：用法线刷修改顶点让顶点平滑，出现这个问题的原因是每个面的法线都是垂直于平面的，所以在边角处就连接不上了。一般这种问题的解决方案是另外存储一套平滑法线。具体做法是计算与该点位置相同的所有点的法线的平均值并存储在顶点上。</li>
<li>描边线条控制<br>想眼睛，头发这种细节描边需要修正的<br>头发，由于模型的复杂性，在使用法线外扩法时往往会出现不太想要的描边。为了防止出现这些不受欢迎的描边，可以给每个顶点设置一个深度值、将顶点埋进里面从而被遮挡住。《罪恶装备Xrd》里就将这个信息写入了顶点色B通道中。<br>细节：由于法线外扩法是基于模型的，所以实际上对线条还是有较高的自由度来控制。如果想要做到有粗细变化的描边，可以参考罪恶装备Xrd中将粗细变化的数值写入顶点色当中。实际上就是一个外扩系数：数值越大，越向外扩，线条越粗。至于线条的颜色，如果顶点色或者其他UV通道够用，可以将描边颜色写进顶点里面。然后相乘。<h2 id="菲涅尔方程"><a href="#菲涅尔方程" class="headerlink" title="菲涅尔方程"></a>菲涅尔方程</h2><h3 id="解决方法"><a href="#解决方法" class="headerlink" title="解决方法"></a>解决方法</h3>N*V<br>适用于球形物体的描边<h3 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h3>但平面时不好控制轮廓线<h2 id="顶点着色器"><a href="#顶点着色器" class="headerlink" title="顶点着色器"></a>顶点着色器</h2>blender  的Freestyle<h3 id="解决方法-1"><a href="#解决方法-1" class="headerlink" title="解决方法"></a>解决方法</h3>他们首先通过预处理的方式提取那些感兴趣的边缘，保存到额外的Mesh资源上。在渲染时通过Geometry Shader将这些边缘绘制出来。<br>出于性能跟兼容性问题还是尽量避免使用Geometry Shader的好。但是这种思路还是非常不错的，因为这种方式对线条的控制也有很高的自由度，并且相比起法线外扩法可以创造更多细节。而且目前Compute Shader已经相当成熟且普及了，所以考虑用Compute Shader＋软光栅的方式说不定也是一条走得通的道路。<h3 id="问题-1"><a href="#问题-1" class="headerlink" title="问题"></a>问题</h3>颜色不能自定义，塞到顶点色里面，而且性价比不高。<h2 id="基于图像空间的线条检测"><a href="#基于图像空间的线条检测" class="headerlink" title="基于图像空间的线条检测"></a>基于图像空间的线条检测</h2></li>
</ol>
<p><a target="_blank" rel="noopener" href="https://game.academy.163.com/course/careerArticle?course=771">参考文章</a><br>通过检测场景图像中 Normal 和 Depth 的不连续性，我们可以获得细节较为丰富的勾线。无论场景的复杂性如何，这种方法的性能都是恒定的，我们还添加了对勾线颜色的色相、明度、饱和度的调整，使勾线更为自然。<br><img src="https://img-blog.csdnimg.cn/3c57005ad1a741d29931a3e186cd7ffe.png" alt="在这里插入图片描述"></p>
<p>常用的算法是Sobel算子<br>缺点则是较难控制勾线的宽度，如果我们想实现距离相关的线宽，我们只能在几个像素的范围内调整它，因此基于图像的方法主要适用于场景线条渲染，对于靠近摄像头很近的物体，我们最好使用 Backface 的方法。<br><img src="https://img-blog.csdnimg.cn/6f6b3473bb4b4711b738976dfeec81d3.png" alt="在这里插入图片描述"><br><a target="_blank" rel="noopener" href="https://game.academy.163.com/course/careerArticle?course=522">看这里实现方式</a></p>
<h2 id="对于后处理进行canny卷积"><a href="#对于后处理进行canny卷积" class="headerlink" title="对于后处理进行canny卷积"></a>对于后处理进行canny卷积</h2><p>我卷失败了，没卷出来以后有时间再搞。<br>和上一方法有异曲同工之处。<br>转化为灰度图进行canny卷积</p>
<h1 id="打光"><a href="#打光" class="headerlink" title="打光"></a>打光</h1><h2 id="皮肤和衣服部分"><a href="#皮肤和衣服部分" class="headerlink" title="皮肤和衣服部分"></a>皮肤和衣服部分</h2><h3 id="多通道Ramp的shading方法"><a href="#多通道Ramp的shading方法" class="headerlink" title="多通道Ramp的shading方法"></a>多通道Ramp的shading方法</h3><p> <img src="https://img-blog.csdnimg.cn/img_convert/5498cba268da6539c44be4ea58fbdf47.png" alt="T_SpecularRamp1.png"><br><img src="https://img-blog.csdnimg.cn/d90f24dfc2e34d13b9e6de9c073f5586.png#pic_center" alt="在这里插入图片描述"><br><img src="https://img-blog.csdnimg.cn/cec471392ce64025a360a5ff3f6f5195.png" alt="在这里插入图片描述"><br>采用多层上色，我的效果好拉，没官方好看。</p>
<h4 id="解释"><a href="#解释" class="headerlink" title="解释"></a>解释</h4><p>RampLayerSoftness越大越软阴影，小则硬<br>我没将_TintBase 叠加上去<br>我没加阴影是因为，当阴影加上后会映在人身上看起来就不二次元了。</p>
<h4 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h4><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br></pre></td><td class="code"><pre><span class="line">Properties :</span><br><span class="line">    [<span class="built_in">Header</span>(Tint Base)]</span><br><span class="line">    _DiffuseRamp (<span class="string">&quot;DiffuseRamp&quot;</span>, <span class="number">2</span>D) = <span class="string">&quot;Black&quot;</span> &#123;&#125;</span><br><span class="line">        _SpecularRamp (<span class="string">&quot;SpecularRamp&quot;</span>, <span class="number">2</span>D) = <span class="string">&quot;Black&quot;</span> &#123;&#125;</span><br><span class="line">        _TintBase (<span class="string">&quot;Tint Base&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer1)]</span><br><span class="line">        _RampLayerOffset1 (<span class="string">&quot;RampLayerOffset1&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _TintLayer1 (<span class="string">&quot;Tint_Layer1&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer2)]</span><br><span class="line">        _RampLayerOffset2 (<span class="string">&quot;RampLayerOffset2&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RampLayerSoftness2 (<span class="string">&quot;RampLayerSoftness2&quot;</span>, <span class="built_in">Range</span>(<span class="number">0</span>,<span class="number">1</span>)) = <span class="number">0.5</span></span><br><span class="line">        __TintLayer2 (<span class="string">&quot;Tint Layer2&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer3)]</span><br><span class="line">        _RampLayerOffset3 (<span class="string">&quot;RampLayerOffset3&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RampLayerSoftness3 (<span class="string">&quot;RampLayerSoftness3&quot;</span>, <span class="built_in">Range</span>(<span class="number">0</span>,<span class="number">1</span>)) = <span class="number">0.5</span></span><br><span class="line">        __TintLayer3 (<span class="string">&quot;Tint Layer3&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(Specular)]</span><br><span class="line">         _Shineness (<span class="string">&quot;Shineness&quot;</span>, Float) = <span class="number">0.5</span></span><br><span class="line">         _SpecularColor (<span class="string">&quot;Specular Color&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">         _SpecularIntensity (<span class="string">&quot;SpecularIntensity&quot;</span>, Float) = <span class="number">1</span></span><br><span class="line">         _SpecularSmooth (<span class="string">&quot;Specular Smooth&quot;</span>, Float) = <span class="number">1</span></span><br><span class="line">Pass :</span><br><span class="line">      sampler2D _DiffuseRamp;</span><br><span class="line">          sampler2D _SpecularRamp;</span><br><span class="line">            float4 _TintBase;</span><br><span class="line">            float4 __TintLayer1;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset1;</span><br><span class="line"></span><br><span class="line">            float4 __TintLayer2;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset2;</span><br><span class="line">            <span class="type">float</span> _RampLayerSoftness2;</span><br><span class="line">            </span><br><span class="line">            float4 __TintLayer3;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset3;</span><br><span class="line">            <span class="type">float</span> _RampLayerSoftness3;</span><br><span class="line"></span><br><span class="line">            <span class="type">float</span> _Shineness;</span><br><span class="line">            <span class="type">float</span> _SpecularIntensity;</span><br><span class="line">            float4 _SpecularColor;</span><br><span class="line">            <span class="type">float</span> _SpecularSmooth;</span><br><span class="line">frag :</span><br><span class="line">        half atten = <span class="built_in">LIGHT_ATTENUATION</span> (i);</span><br><span class="line">                half3 base_col = <span class="built_in">tex2D</span>(_MainTex, i.uv).xyz;</span><br><span class="line">                half3 normal_world= <span class="built_in">normalize</span>(i.normalDir);</span><br><span class="line">                half3 tangent_world= <span class="built_in">normalize</span>(i.tangentDir);</span><br><span class="line">                half3 binormal_world= <span class="built_in">normalize</span>(i.binormalDir);</span><br><span class="line">                half3 pos_world= <span class="built_in">normalize</span>(i.pos_world);</span><br><span class="line">                half3 normal_data = <span class="built_in">UnpackNormal</span>(<span class="built_in">tex2D</span>(_Normal,i.uv));</span><br><span class="line">                half3x3 TBN = <span class="built_in">half3x3</span> (tangent_world,binormal_world,normal_world);</span><br><span class="line">                </span><br><span class="line">                normal_world = <span class="built_in">mul</span>(normal_data,TBN);</span><br><span class="line">                half3 ViewDir = <span class="built_in">normalize</span>(_WorldSpaceCameraPos.xyz-pos_world);</span><br><span class="line">                half3 lightDir = <span class="built_in">normalize</span>(_WorldSpaceLightPos0.xyz);</span><br><span class="line">                <span class="comment">//漫反射</span></span><br><span class="line">                half NdotL =  <span class="built_in">max</span>(<span class="number">0</span>,<span class="built_in">dot</span>(normal_world,lightDir));</span><br><span class="line">                half half_lambert = (NdotL+<span class="number">1.0</span>)*<span class="number">0.5</span>;</span><br><span class="line">                <span class="comment">//half half_lambert = half_lambert*ao //本来要乘上AO因为素材没有算了</span></span><br><span class="line"></span><br><span class="line">                half3 tint_Base_color1 = base_col;</span><br><span class="line"></span><br><span class="line">                <span class="comment">//第一层ramp</span></span><br><span class="line">                half2 uv_ramp1 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset1,<span class="number">0.5</span>);</span><br><span class="line">                half toon_diffuse1 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp1).r;</span><br><span class="line">                half3 tint_color1 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer1,toon_diffuse1*__TintLayer1.a);</span><br><span class="line">                </span><br><span class="line">                <span class="comment">//第二层ramp</span></span><br><span class="line">                half2 uv_ramp2 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset2,<span class="number">1</span>-i.VertexColor.g+_RampLayerSoftness2);<span class="comment">//1-i.VertexColor.g可以用_RampLayerSoftness2代替越大越柔和</span></span><br><span class="line">                half toon_diffuse2 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp2).g;</span><br><span class="line">                half3 tint_color2 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer2,toon_diffuse2*__TintLayer2.a);</span><br><span class="line">                </span><br><span class="line">                <span class="comment">//第三层ramp</span></span><br><span class="line">                half2 uv_ramp3 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset3,<span class="number">1</span>-i.VertexColor.b+_RampLayerSoftness3);<span class="comment">//1-i.VertexColor.b可以用_RampLayerSoftness3代替越大越柔和</span></span><br><span class="line">                half toon_diffuse3 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp3).b;</span><br><span class="line">                half3 tint_color3 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer3,toon_diffuse3*__TintLayer3.a);</span><br><span class="line">                </span><br><span class="line">                half3 final_diffuse = tint_Base_color1 * tint_color1 *tint_color2 *tint_color3  ;</span><br><span class="line">                <span class="comment">//高光</span></span><br><span class="line">                <span class="comment">//half3 half_R = normalize(lightDir+ViewDir);</span></span><br><span class="line">                half3 R = <span class="built_in">normalize</span>(<span class="built_in">reflect</span>(-lightDir,normal_world));</span><br><span class="line">                half specular_term = <span class="built_in">max</span>(<span class="built_in">pow</span>(<span class="built_in">dot</span>(R,ViewDir),_Shineness),<span class="number">0.0001</span>);<span class="comment">//本来要乘上AO因为素材没有算了</span></span><br><span class="line">                specular_term = <span class="built_in">smoothstep</span>(<span class="number">0.5</span>-_SpecularSmooth*<span class="number">0.5</span>,<span class="number">0.5</span>+_SpecularSmooth*<span class="number">0.5</span>,specular_term);<span class="comment">//风格化高光</span></span><br><span class="line">            </span><br><span class="line">                half3 final_specular = base_col  * specular_term *_SpecularColor *atten *_LightColor0.xyz *_SpecularIntensity  ;</span><br><span class="line">               half3 final_col = final_diffuse+final_specular ;</span><br></pre></td></tr></table></figure>

<h3 id="卖家秀"><a href="#卖家秀" class="headerlink" title="卖家秀"></a>卖家秀</h3><p><img src="https://img-blog.csdnimg.cn/0208c26a6f904323b643231225ead81a.png" alt="在这里插入图片描述"></p>
<h3 id="买家秀"><a href="#买家秀" class="headerlink" title="买家秀"></a>买家秀</h3><p><img src="https://img-blog.csdnimg.cn/48f78fef3cee4385902745f21bd42f3a.png" alt="在这里插入图片描述"></p>
<h3 id="边缘光，环境光"><a href="#边缘光，环境光" class="headerlink" title="边缘光，环境光"></a>边缘光，环境光</h3><p><img src="https://img-blog.csdnimg.cn/a2ed782f9f1d4108b0b154e904144cef.png" alt="在这里插入图片描述"></p>
<h4 id="解释-1"><a href="#解释-1" class="headerlink" title="解释"></a>解释</h4><p>_MatCap是我自己加上去的，有点多余</p>
<h4 id="实现"><a href="#实现" class="headerlink" title="实现"></a>实现</h4><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">Properties :</span><br><span class="line">    _MatCap (<span class="string">&quot;MatCap&quot;</span>, <span class="number">2</span>D) = <span class="string">&quot;Black&quot;</span> &#123;&#125;</span><br><span class="line">        _Envmap (<span class="string">&quot;Envmap&quot;</span>, Cube) = <span class="string">&quot;Black&quot;</span> &#123;&#125;</span><br><span class="line">        [<span class="built_in">Header</span>(Rim)]</span><br><span class="line">        _RimMin(<span class="string">&quot;RimMin&quot;</span>, <span class="built_in">Range</span>(<span class="number">-2</span>,<span class="number">2</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RimMax(<span class="string">&quot;RimMax&quot;</span>, <span class="built_in">Range</span>(<span class="number">-2</span>,<span class="number">2</span>)) = <span class="number">0.5</span></span><br><span class="line">        _Roughness(<span class="string">&quot;Roughness&quot;</span>, Float) = <span class="number">0</span></span><br><span class="line">        _EnvIntensity(<span class="string">&quot;Env Intensity&quot;</span>, Float) = <span class="number">0</span></span><br><span class="line">pass :</span><br><span class="line">            sampler2D _MatCap;</span><br><span class="line">            samplerCUBE _Envmap;</span><br><span class="line">            <span class="type">float</span> _RimMax;</span><br><span class="line">            <span class="type">float</span> _RimMin;</span><br><span class="line">            <span class="type">float</span> _Roughness;</span><br><span class="line">            <span class="type">float</span> _EnvIntensity;</span><br><span class="line">            float4 _Envmap_HDR;</span><br><span class="line">frag :</span><br><span class="line">        <span class="comment">//边缘光,环境光</span></span><br><span class="line">                </span><br><span class="line">                half fresnel = <span class="number">1</span>- <span class="built_in">dot</span>(ViewDir,normal_world);</span><br><span class="line">                half rim = <span class="built_in">smoothstep</span>(_RimMin,_RimMax,fresnel);<span class="comment">//本来要乘上AO因为素材没有算了</span></span><br><span class="line">                half3 mc=<span class="built_in">tex2D</span>(_MatCap,fresnel.xx);</span><br><span class="line">                half3 r = <span class="built_in">reflect</span>(-ViewDir,normal_world);</span><br><span class="line">                half roughness = <span class="built_in">lerp</span>(<span class="number">0</span>,<span class="number">0.95</span>,<span class="built_in">saturate</span>(_Roughness));</span><br><span class="line">                roughness = roughness * (<span class="number">1.7</span><span class="number">-0.7</span>*roughness );</span><br><span class="line">                half mip_level = roughness * <span class="number">6.0</span>;</span><br><span class="line">                half4 color_cubemap = <span class="built_in">texCUBElod</span>(_Envmap,<span class="built_in">half4</span>(r,mip_level));</span><br><span class="line">                half3 color_env = <span class="built_in">DecodeHDR</span>(color_cubemap,_Envmap_HDR);</span><br><span class="line">                half3 final_env =color_env * rim * _EnvIntensity;</span><br></pre></td></tr></table></figure>
<h3 id="总体代码"><a href="#总体代码" class="headerlink" title="总体代码"></a>总体代码</h3><p>Character_Skin.shader</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br></pre></td><td class="code"><pre><span class="line">Shader <span class="string">&quot;Character/Skin&quot;</span></span><br><span class="line">&#123;</span><br><span class="line">    Properties</span><br><span class="line">    &#123;</span><br><span class="line">        _MainTex (<span class="string">&quot;MainTex&quot;</span>, <span class="number">2</span>D) = <span class="string">&quot;white&quot;</span> &#123;&#125;</span><br><span class="line">        _Normal(<span class="string">&quot;Normal&quot;</span>,<span class="number">2</span>D) = <span class="string">&quot;bump&quot;</span> &#123;&#125;</span><br><span class="line">        _DiffuseRamp (<span class="string">&quot;DiffuseRamp&quot;</span>, <span class="number">2</span>D) = <span class="string">&quot;Black&quot;</span> &#123;&#125;</span><br><span class="line">        _Envmap (<span class="string">&quot;Envmap&quot;</span>, Cube) = <span class="string">&quot;Black&quot;</span> &#123;&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        [<span class="built_in">Header</span>(Tint Base)]</span><br><span class="line">        _TintBase (<span class="string">&quot;Tint Base&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer1)]</span><br><span class="line">        _RampLayerOffset1 (<span class="string">&quot;RampLayerOffset1&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _TintLayer1 (<span class="string">&quot;Tint_Layer1&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer2)]</span><br><span class="line">        _RampLayerOffset2 (<span class="string">&quot;RampLayerOffset2&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RampLayerSoftness2 (<span class="string">&quot;RampLayerSoftness2&quot;</span>, <span class="built_in">Range</span>(<span class="number">0</span>,<span class="number">1</span>)) = <span class="number">0.5</span></span><br><span class="line">        __TintLayer2 (<span class="string">&quot;Tint Layer2&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer3)]</span><br><span class="line">        _RampLayerOffset3 (<span class="string">&quot;RampLayerOffset3&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RampLayerSoftness3 (<span class="string">&quot;RampLayerSoftness3&quot;</span>, <span class="built_in">Range</span>(<span class="number">0</span>,<span class="number">1</span>)) = <span class="number">0.5</span></span><br><span class="line">        __TintLayer3 (<span class="string">&quot;Tint Layer3&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(Specular)]</span><br><span class="line">         _Shineness (<span class="string">&quot;Shineness&quot;</span>, Float) = <span class="number">0.5</span></span><br><span class="line">         _SpecularColor (<span class="string">&quot;Specular Color&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">         _SpecularIntensity (<span class="string">&quot;SpecularIntensity&quot;</span>, Float) = <span class="number">1</span></span><br><span class="line">         _SpecularSmooth (<span class="string">&quot;Specular Smooth&quot;</span>, Float) = <span class="number">1</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        [<span class="built_in">Header</span>(Rim)]</span><br><span class="line">        _RimMin(<span class="string">&quot;RimMin&quot;</span>, <span class="built_in">Range</span>(<span class="number">-2</span>,<span class="number">2</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RimMax(<span class="string">&quot;RimMax&quot;</span>, <span class="built_in">Range</span>(<span class="number">-2</span>,<span class="number">2</span>)) = <span class="number">0.5</span></span><br><span class="line">        _Roughness(<span class="string">&quot;Roughness&quot;</span>, Float) = <span class="number">0</span></span><br><span class="line">        _EnvIntensity(<span class="string">&quot;Env Intensity&quot;</span>, Float) = <span class="number">0</span></span><br><span class="line"></span><br><span class="line">        [<span class="built_in">Header</span>(Outline)]</span><br><span class="line">        _Outline (<span class="string">&quot;Outline&quot;</span>, Float) = <span class="number">0.6</span></span><br><span class="line">        _OutlineColor (<span class="string">&quot;OutlineColor&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">    &#125;</span><br><span class="line">    SubShader</span><br><span class="line">    &#123;</span><br><span class="line">        Tags &#123; <span class="string">&quot;RenderType&quot;</span>=<span class="string">&quot;Opaque&quot;</span> &#125;</span><br><span class="line">        LOD <span class="number">100</span></span><br><span class="line">        </span><br><span class="line">        Pass</span><br><span class="line">        &#123;</span><br><span class="line">            Name <span class="string">&quot;Skin&quot;</span></span><br><span class="line">            Tags &#123; <span class="string">&quot;LightMode&quot;</span> = <span class="string">&quot;ForwardBase&quot;</span> &#125;</span><br><span class="line">            </span><br><span class="line">            CGPROGRAM</span><br><span class="line">            </span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> vertex vert</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> fragment frag</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> multi_compile_fwdbase</span></span><br><span class="line">            <span class="comment">// make fog work</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> multi_compile_fog</span></span><br><span class="line">            <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;AutoLight.cginc&quot;</span></span></span><br><span class="line">            <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;UnityCG.cginc&quot;</span></span></span><br><span class="line"></span><br><span class="line">            <span class="keyword">struct</span> appdata</span><br><span class="line">            &#123;</span><br><span class="line">                float4 vertex : POSITION;</span><br><span class="line">                float2 texcoord0 : TEXCOORD0;</span><br><span class="line">                float4 normal :NORMAL;</span><br><span class="line">                float4 tangent:TANGENT;</span><br><span class="line">                float4 VertexColor:COLOR;</span><br><span class="line">            &#125;;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">struct</span> <span class="title class_">v2f</span></span><br><span class="line">            &#123;</span><br><span class="line">                </span><br><span class="line">                float4 pos : SV_POSITION;</span><br><span class="line">                float2 uv : TEXCOORD0;</span><br><span class="line"></span><br><span class="line">                float3 normalDir: TEXCOORD1;</span><br><span class="line">                float3 tangentDir: TEXCOORD2;</span><br><span class="line">                float3 binormalDir: TEXCOORD3;</span><br><span class="line">                float4 VertexColor: TEXCOORD4;</span><br><span class="line">                float3 pos_world: TEXCOORD5;</span><br><span class="line">                <span class="built_in">LIGHTING_COORDS</span>(<span class="number">6</span>,<span class="number">7</span>)</span><br><span class="line">            &#125;;</span><br><span class="line"></span><br><span class="line">            sampler2D _MainTex;</span><br><span class="line">            sampler2D _Normal;</span><br><span class="line">            sampler2D _DiffuseRamp;</span><br><span class="line">            samplerCUBE _Envmap;</span><br><span class="line"></span><br><span class="line">            float4 _LightColor0;</span><br><span class="line"></span><br><span class="line">            float4 _MainTex_ST;</span><br><span class="line">            float4 _TintBase;</span><br><span class="line">            float4 __TintLayer1;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset1;</span><br><span class="line"></span><br><span class="line">            float4 __TintLayer2;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset2;</span><br><span class="line">            <span class="type">float</span> _RampLayerSoftness2;</span><br><span class="line">            </span><br><span class="line">            float4 __TintLayer3;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset3;</span><br><span class="line">            <span class="type">float</span> _RampLayerSoftness3;</span><br><span class="line"></span><br><span class="line">            <span class="type">float</span> _Shineness;</span><br><span class="line">            <span class="type">float</span> _SpecularIntensity;</span><br><span class="line">            float4 _SpecularColor;</span><br><span class="line">            <span class="type">float</span> _SpecularSmooth;</span><br><span class="line"></span><br><span class="line">            <span class="type">float</span> _RimMax;</span><br><span class="line">            <span class="type">float</span> _RimMin;</span><br><span class="line">            <span class="type">float</span> _Roughness;</span><br><span class="line">            <span class="type">float</span> _EnvIntensity;</span><br><span class="line">            float4 _Envmap_HDR;</span><br><span class="line"></span><br><span class="line">            <span class="function">v2f <span class="title">vert</span> <span class="params">(appdata v)</span></span></span><br><span class="line"><span class="function">            </span>&#123;</span><br><span class="line">                v2f o;</span><br><span class="line">                o.pos = <span class="built_in">UnityObjectToClipPos</span>(v.vertex);</span><br><span class="line">                o.uv = v.texcoord0;</span><br><span class="line">                o.normalDir=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.normal).xyz);</span><br><span class="line">                o.tangentDir=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.tangent).xyz);</span><br><span class="line">                o.pos_world=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.vertex).xyz);</span><br><span class="line">                o.binormalDir=<span class="built_in">normalize</span>( <span class="built_in">cross</span>(o.normalDir,o.tangentDir)*v.tangent.w);</span><br><span class="line">                o.VertexColor = v.VertexColor;</span><br><span class="line">                <span class="built_in">TRANSFER_VERTEX_TO_FRAGMENT</span>(o);</span><br><span class="line">                <span class="keyword">return</span> o;   </span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="function">half4 <span class="title">frag</span> <span class="params">(v2f i)</span> : SV_Target</span></span><br><span class="line"><span class="function">            &#123;</span></span><br><span class="line">                <span class="comment">// sample the texture</span></span><br><span class="line">                half atten = <span class="built_in">LIGHT_ATTENUATION</span> (i);</span><br><span class="line">                half3 base_col = <span class="built_in">tex2D</span>(_MainTex, i.uv).xyz;</span><br><span class="line">                half3 normal_world= <span class="built_in">normalize</span>(i.normalDir);</span><br><span class="line">                half3 tangent_world= <span class="built_in">normalize</span>(i.tangentDir);</span><br><span class="line">                half3 binormal_world= <span class="built_in">normalize</span>(i.binormalDir);</span><br><span class="line">                half3 pos_world= <span class="built_in">normalize</span>(i.pos_world);</span><br><span class="line">                half3 normal_data = <span class="built_in">UnpackNormal</span>(<span class="built_in">tex2D</span>(_Normal,i.uv));</span><br><span class="line">                half3x3 TBN = <span class="built_in">half3x3</span> (tangent_world,binormal_world,normal_world);</span><br><span class="line">                </span><br><span class="line">                normal_world = <span class="built_in">mul</span>(normal_data,TBN);</span><br><span class="line">                half3 ViewDir = <span class="built_in">normalize</span>(_WorldSpaceCameraPos.xyz-pos_world);</span><br><span class="line">                half3 lightDir = <span class="built_in">normalize</span>(_WorldSpaceLightPos0.xyz);</span><br><span class="line">                <span class="comment">//漫反射</span></span><br><span class="line">                half NdotL =  <span class="built_in">max</span>(<span class="number">0</span>,<span class="built_in">dot</span>(normal_world,lightDir));</span><br><span class="line">                half half_lambert = (NdotL+<span class="number">1.0</span>)*<span class="number">0.5</span>;</span><br><span class="line">                <span class="comment">//half half_lambert = half_lambert*ao //本来要乘上AO因为素材没有算了</span></span><br><span class="line"></span><br><span class="line">                half3 tint_Base_color1 = base_col;</span><br><span class="line"></span><br><span class="line">                <span class="comment">//第一层ramp</span></span><br><span class="line">                half2 uv_ramp1 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset1,<span class="number">0.5</span>);</span><br><span class="line">                half toon_diffuse1 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp1).r;</span><br><span class="line">                half3 tint_color1 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer1,toon_diffuse1*__TintLayer1.a);</span><br><span class="line">                </span><br><span class="line">                <span class="comment">//第二层ramp</span></span><br><span class="line">                half2 uv_ramp2 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset2,<span class="number">1</span>-i.VertexColor.g+_RampLayerSoftness2);<span class="comment">//1-i.VertexColor.g可以用_RampLayerSoftness2代替越大越柔和</span></span><br><span class="line">                half toon_diffuse2 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp2).g;</span><br><span class="line">                half3 tint_color2 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer2,toon_diffuse2*__TintLayer2.a);</span><br><span class="line">                </span><br><span class="line">                <span class="comment">//第三层ramp</span></span><br><span class="line">                half2 uv_ramp3 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset3,<span class="number">1</span>-i.VertexColor.b+_RampLayerSoftness3);<span class="comment">//1-i.VertexColor.b可以用_RampLayerSoftness3代替越大越柔和</span></span><br><span class="line">                half toon_diffuse3 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp3).b;</span><br><span class="line">                half3 tint_color3 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer3,toon_diffuse3*__TintLayer3.a);</span><br><span class="line">                </span><br><span class="line">                half3 final_diffuse = tint_Base_color1 * tint_color1 *tint_color2 *tint_color3  ;</span><br><span class="line">                <span class="comment">//高光</span></span><br><span class="line">                <span class="comment">//half3 half_R = normalize(lightDir+ViewDir);</span></span><br><span class="line">                half3 R = <span class="built_in">normalize</span>(<span class="built_in">reflect</span>(-lightDir,normal_world));</span><br><span class="line">                half specular_term = <span class="built_in">max</span>(<span class="built_in">pow</span>(<span class="built_in">dot</span>(R,ViewDir),_Shineness),<span class="number">0.0001</span>);<span class="comment">//本来要乘上AO因为素材没有算了</span></span><br><span class="line">                specular_term = <span class="built_in">smoothstep</span>(<span class="number">0.5</span>-_SpecularSmooth*<span class="number">0.5</span>,<span class="number">0.5</span>+_SpecularSmooth*<span class="number">0.5</span>,specular_term);<span class="comment">//风格化高光</span></span><br><span class="line">            </span><br><span class="line">                half3 final_specular = base_col  * specular_term *_SpecularColor *atten *_LightColor0.xyz *_SpecularIntensity  ;</span><br><span class="line">                </span><br><span class="line">                <span class="comment">//边缘光,环境光</span></span><br><span class="line">                half NDL = NdotL&gt;<span class="number">0</span> ? <span class="number">1</span>:<span class="number">0</span>;</span><br><span class="line">                half fresnel = <span class="number">1</span>- <span class="built_in">dot</span>(ViewDir,normal_world);</span><br><span class="line">                half rim = <span class="built_in">smoothstep</span>(_RimMin,_RimMax,fresnel);<span class="comment">//本来要乘上AO因为素材没有算了</span></span><br><span class="line">                rim = rim * NDL;</span><br><span class="line"></span><br><span class="line">                half3 r = <span class="built_in">reflect</span>(-ViewDir,normal_world);</span><br><span class="line">                half roughness = <span class="built_in">lerp</span>(<span class="number">0</span>,<span class="number">0.95</span>,<span class="built_in">saturate</span>(_Roughness));</span><br><span class="line">                roughness = roughness * (<span class="number">1.7</span><span class="number">-0.7</span>*roughness );</span><br><span class="line">                half mip_level = roughness * <span class="number">6.0</span>;</span><br><span class="line">                half4 color_cubemap = <span class="built_in">texCUBElod</span>(_Envmap,<span class="built_in">half4</span>(r,mip_level));</span><br><span class="line">                half3 color_env = <span class="built_in">DecodeHDR</span>(color_cubemap,_Envmap_HDR);</span><br><span class="line">                half3 final_env =color_env * rim * _EnvIntensity    ;</span><br><span class="line"></span><br><span class="line">                half3 final_col = final_diffuse+final_specular + final_env;</span><br><span class="line">                <span class="keyword">return</span> <span class="built_in">half4</span>(final_col,<span class="number">1</span>);</span><br><span class="line">                </span><br><span class="line">            &#125;</span><br><span class="line">            ENDCG</span><br><span class="line">        &#125;</span><br><span class="line">        Pass</span><br><span class="line">        &#123;</span><br><span class="line">        Name <span class="string">&quot;OUTLINE&quot;</span></span><br><span class="line">        Cull Front</span><br><span class="line">    ZWrite On</span><br><span class="line">    ColorMask RGB</span><br><span class="line">    Blend SrcAlpha OneMinusSrcAlpha</span><br><span class="line">            CGPROGRAM</span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> vertex vert</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> fragment frag</span></span><br><span class="line">            <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;UnityCG.cginc&quot;</span></span></span><br><span class="line">            <span class="keyword">struct</span> <span class="title class_">appdata</span> &#123;</span><br><span class="line">            float4 vertex : POSITION;</span><br><span class="line">            float3 normal : NORMAL;</span><br><span class="line">            float4 texCoord : TEXCOORD0;</span><br><span class="line">            float4 vertexColor : COLOR;</span><br><span class="line">          &#125;;</span><br><span class="line">          <span class="keyword">struct</span> <span class="title class_">v2f</span> &#123;</span><br><span class="line">          	float4 pos : POSITION;</span><br><span class="line">          	float4 color : COLOR;</span><br><span class="line">          	float4 tex : TEXCOORD0;</span><br><span class="line">          &#125;;</span><br><span class="line">            sampler2D _MainTex;</span><br><span class="line">            <span class="type">float</span> _Outline;</span><br><span class="line">            float4 _OutlineColor;</span><br><span class="line">            <span class="function">v2f <span class="title">vert</span><span class="params">(appdata v)</span> </span>&#123;</span><br><span class="line">            <span class="comment">// just make a copy of incoming vertex data but scaled according to normal direction</span></span><br><span class="line">          	v2f o;</span><br><span class="line">          	o.pos = <span class="built_in">UnityObjectToClipPos</span>(v.vertex);</span><br><span class="line">            float3 norm = <span class="built_in">mul</span>((float3x3)UNITY_MATRIX_IT_MV, v.normal);</span><br><span class="line">            float2 offset = <span class="built_in">TransformViewToProjection</span>(norm.xy);</span><br><span class="line">           <span class="comment">// float2 offset = (norm.xy);</span></span><br><span class="line">          	o.pos.xy += offset * _Outline*<span class="number">0.0001</span>;</span><br><span class="line">          	o.tex = v.texCoord;</span><br><span class="line">          	o.color = v.vertexColor;</span><br><span class="line">          	<span class="keyword">return</span> o;</span><br><span class="line">          &#125;</span><br><span class="line">            <span class="function">fixed4 <span class="title">frag</span> <span class="params">(v2f i)</span> : SV_Target</span></span><br><span class="line"><span class="function">            &#123;</span></span><br><span class="line">                half4 base_col = <span class="built_in">tex2D</span>(_MainTex,i.tex);</span><br><span class="line">                <span class="keyword">return</span> _OutlineColor*base_col;</span><br><span class="line">            &#125;</span><br><span class="line">            ENDCG</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    FallBack <span class="string">&quot;Diffuse&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="眼睛"><a href="#眼睛" class="headerlink" title="眼睛"></a>眼睛</h2><p>眼睛折射效果，我的模型不需要进行眼球移动，也不适合做这个，所以没弄<br>其中uworld和vworld是指UV线在世界空间下在方向。<br><img src="https://img-blog.csdnimg.cn/4a670d4f998c4f1c9be3cec05961a865.png" alt="在这里插入图片描述"><br>以下也没搞清除<br><img src="https://img-blog.csdnimg.cn/2554930d4bee4ad0b36a2746d1f7a8e5.png" alt="在这里插入图片描述"></p>
<h3 id="关于头发遮挡眼睛，解决办法"><a href="#关于头发遮挡眼睛，解决办法" class="headerlink" title="关于头发遮挡眼睛，解决办法"></a>关于头发遮挡眼睛，解决办法</h3><h4 id="模板测试"><a href="#模板测试" class="headerlink" title="模板测试"></a>模板测试</h4><p>在进行眼睛渲染的Pass时，将模板值设置为某一固定值：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">Stencil &#123;</span><br><span class="line">   Ref <span class="number">1</span></span><br><span class="line">   Comp Always</span><br><span class="line">   Pass Replace</span><br><span class="line">   Fail Replace</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>头发等遮挡部分</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">Stencil &#123;</span><br><span class="line">     Ref <span class="number">1</span></span><br><span class="line">     Comp NotEqual</span><br><span class="line">     Pass Keep</span><br><span class="line">     Fail Keep</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/cf076006cd9746778c51ebf8c4bae008.png" alt="在这里插入图片描述"></p>
<h4 id="将遮挡脸部透明部分写入顶点色A通道"><a href="#将遮挡脸部透明部分写入顶点色A通道" class="headerlink" title="将遮挡脸部透明部分写入顶点色A通道"></a>将遮挡脸部透明部分写入顶点色A通道</h4><p>将头发渲染队列改为Transparent<br>让最后输出的颜色的A等于顶点色A</p>
<h3 id="Eye-shader"><a href="#Eye-shader" class="headerlink" title="Eye.shader"></a>Eye.shader</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br></pre></td><td class="code"><pre><span class="line">Shader <span class="string">&quot;Character/Eye&quot;</span></span><br><span class="line">&#123;</span><br><span class="line">    Properties</span><br><span class="line">    &#123;</span><br><span class="line">       _MainTex (<span class="string">&quot;MainTex&quot;</span>, <span class="number">2</span>D) = <span class="string">&quot;white&quot;</span> &#123;&#125;</span><br><span class="line">       _Normal(<span class="string">&quot;Normal&quot;</span>,<span class="number">2</span>D) = <span class="string">&quot;bump&quot;</span> &#123;&#125;</span><br><span class="line">       </span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    SubShader</span><br><span class="line">    &#123;</span><br><span class="line">        Tags &#123; <span class="string">&quot;RenderType&quot;</span>=<span class="string">&quot;Opaque&quot;</span> &#125;</span><br><span class="line">        LOD <span class="number">100</span></span><br><span class="line">        </span><br><span class="line">        Pass</span><br><span class="line">        &#123;</span><br><span class="line">          Stencil &#123;</span><br><span class="line">             Ref <span class="number">1</span></span><br><span class="line">             Comp Always</span><br><span class="line">             Pass Replace</span><br><span class="line">             Fail Replace</span><br><span class="line">          &#125;</span><br><span class="line">           Name <span class="string">&quot;Eye&quot;</span></span><br><span class="line">            Tags &#123; <span class="string">&quot;LightMode&quot;</span> = <span class="string">&quot;ForwardBase&quot;</span> &#125;</span><br><span class="line">            </span><br><span class="line">            CGPROGRAM</span><br><span class="line">            </span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> vertex vert</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> fragment frag</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> multi_compile_fwdbase</span></span><br><span class="line">            <span class="comment">// make fog work</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> multi_compile_fog</span></span><br><span class="line">            <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;AutoLight.cginc&quot;</span></span></span><br><span class="line">            <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;UnityCG.cginc&quot;</span></span></span><br><span class="line"></span><br><span class="line">            <span class="keyword">struct</span> appdata</span><br><span class="line">            &#123;</span><br><span class="line">                float4 vertex : POSITION;</span><br><span class="line">                float2 texcoord0 : TEXCOORD0;</span><br><span class="line">                float4 normal :NORMAL;</span><br><span class="line">                float4 tangent:TANGENT;</span><br><span class="line">                float4 VertexColor:COLOR;</span><br><span class="line">            &#125;;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">struct</span> <span class="title class_">v2f</span></span><br><span class="line">            &#123;</span><br><span class="line">                </span><br><span class="line">                float4 pos : SV_POSITION;</span><br><span class="line">                float2 uv : TEXCOORD0;</span><br><span class="line"></span><br><span class="line">                float3 normalDir: TEXCOORD1;</span><br><span class="line">                float3 tangentDir: TEXCOORD2;</span><br><span class="line">                float3 binormalDir: TEXCOORD3;</span><br><span class="line">                float4 VertexColor: TEXCOORD4;</span><br><span class="line">                float3 pos_world: TEXCOORD5;</span><br><span class="line">                <span class="built_in">LIGHTING_COORDS</span>(<span class="number">6</span>,<span class="number">7</span>)</span><br><span class="line">            &#125;;</span><br><span class="line"></span><br><span class="line">            sampler2D _MainTex;</span><br><span class="line">            sampler2D _Normal;</span><br><span class="line">            float4 _MainTex_ST;</span><br><span class="line"></span><br><span class="line">            <span class="function">v2f <span class="title">vert</span> <span class="params">(appdata v)</span></span></span><br><span class="line"><span class="function">            </span>&#123;</span><br><span class="line">                v2f o;</span><br><span class="line">                o.pos = <span class="built_in">UnityObjectToClipPos</span>(v.vertex);</span><br><span class="line">                o.uv = v.texcoord0;</span><br><span class="line">                o.normalDir=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.normal).xyz);</span><br><span class="line">                o.tangentDir=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.tangent).xyz);</span><br><span class="line">                o.pos_world=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.vertex).xyz);</span><br><span class="line">                o.binormalDir=<span class="built_in">normalize</span>( <span class="built_in">cross</span>(o.normalDir,o.tangentDir)*v.tangent.w);</span><br><span class="line">                o.VertexColor = v.VertexColor;</span><br><span class="line">                <span class="built_in">TRANSFER_VERTEX_TO_FRAGMENT</span>(o);</span><br><span class="line">                <span class="keyword">return</span> o;   </span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="function">fixed4 <span class="title">frag</span> <span class="params">(v2f i)</span> : SV_Target</span></span><br><span class="line"><span class="function">            &#123;</span></span><br><span class="line">                <span class="comment">// sample the texture</span></span><br><span class="line">                fixed4 base_col = <span class="built_in">tex2D</span>(_MainTex, i.uv);</span><br><span class="line">                half3 normal_world= <span class="built_in">normalize</span>(i.normalDir);</span><br><span class="line">                half3 tangent_world= <span class="built_in">normalize</span>(i.tangentDir);</span><br><span class="line">                half3 binormal_world= <span class="built_in">normalize</span>(i.binormalDir);</span><br><span class="line">                half3 normal_data = <span class="built_in">UnpackNormal</span>(<span class="built_in">tex2D</span>(_Normal,i.uv));</span><br><span class="line">                half3x3 TBN = <span class="built_in">half3x3</span> (tangent_world,binormal_world,normal_world);</span><br><span class="line">                normal_world = <span class="built_in">mul</span>(TBN,normal_world);</span><br><span class="line">                half3 ViewDir = <span class="built_in">normalize</span>(_WorldSpaceCameraPos.xyz-i.pos_world);</span><br><span class="line">                half3 lightDir = <span class="built_in">normalize</span>(_WorldSpaceLightPos0.xyz);</span><br><span class="line">                half fresnel = <span class="number">1</span>- <span class="built_in">saturate</span>(<span class="built_in">dot</span>(normal_world ,ViewDir ));</span><br><span class="line">                <span class="keyword">return</span> base_col;</span><br><span class="line">               <span class="comment">// return half4(normal_world,1);</span></span><br><span class="line">            &#125;</span><br><span class="line">            ENDCG</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    FallBack <span class="string">&quot;Diffuse&quot;</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="头发"><a href="#头发" class="headerlink" title="头发"></a>头发</h2><p>各项异性高光<br><a target="_blank" rel="noopener" href="https://mrchenlreanspace.github.io/2022/04/14/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E4%BA%BA%E7%89%A9%E6%B8%B2%E6%9F%93/">原理见移动人物渲染</a></p>
<h3 id="使用shiftmap增强质感"><a href="#使用shiftmap增强质感" class="headerlink" title="使用shiftmap增强质感"></a>使用shiftmap增强质感</h3><p><img src="https://img-blog.csdnimg.cn/dca88625635742ddbd47a85080ab8244.png" alt="在这里插入图片描述"></p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">half2 uv_shift = i.uv * _ShiftRamp_ST.xy + _ShiftRamp_ST.zw;</span><br><span class="line">half3 shift_col = <span class="built_in">tex2D</span>(_ShiftRamp,uv_shift);</span><br><span class="line">binormal_world = <span class="built_in">normalize</span>( binormal_world + (shift_col+_ShiftOffset)* normal_world);</span><br></pre></td></tr></table></figure>
<p>_ShiftRamp_ST.x调节质感，_ShiftOffset调节头发的上下偏移</p>
<h3 id="初版"><a href="#初版" class="headerlink" title="初版"></a>初版</h3><p>通过shininess调节柔和度<br>调大shininess让过度变硬</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">half <span class="title">StrandSpecular</span><span class="params">(half3 T, half3 V, half3 L, half exponent)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">     half3 H = <span class="built_in">normalize</span>(L + V);</span><br><span class="line">     half dotTH = <span class="built_in">dot</span>(T, H);</span><br><span class="line">     half sinTH = <span class="built_in">sqrt</span>(<span class="number">1</span> - dotTH * dotTH);</span><br><span class="line">     half dirAtten = <span class="built_in">smoothstep</span>(<span class="number">-1.0</span>, <span class="number">0.0</span>, dotTH);</span><br><span class="line">     <span class="keyword">return</span> dirAtten * <span class="built_in">pow</span>(sinTH, exponent);</span><br><span class="line">&#125;</span><br><span class="line">half3 final_specular =    <span class="built_in">StrandSpecular</span>(binormal_world,lightDir,ViewDir,_Shineness)*_SpecularColor;</span><br></pre></td></tr></table></figure>
<h3 id="改进"><a href="#改进" class="headerlink" title="改进"></a>改进</h3><p>把柔和度调整到0，1中通过shininess值</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">half NdotV = <span class="built_in">max</span>(<span class="number">0.0</span> ,<span class="built_in">dot</span>(normal_world , ViewDir));</span><br><span class="line">half3 H = <span class="built_in">normalize</span>(lightDir+ViewDir);</span><br><span class="line">half NdotH = <span class="built_in">dot</span>(normal_world ,H );</span><br><span class="line">half TdotH = <span class="built_in">dot</span>(tangent_world ,H);</span><br><span class="line">half BdotH = <span class="built_in">dot</span>(binormal_world ,H);</span><br><span class="line"></span><br><span class="line">BdotH /=_Shineness;</span><br><span class="line">half spec_term =<span class="built_in">exp</span>(-(TdotH*TdotH+BdotH*BdotH)/(<span class="number">1.0</span>+NdotH));</span><br><span class="line">half spec_atten = <span class="built_in">saturate</span>(<span class="built_in">sqrt</span>(<span class="built_in">max</span>(<span class="number">0.0</span>,half_lambert/NdotV)));</span><br><span class="line">half3 final_specular =    spec_term*spec_atten*_SpecularColor;</span><br></pre></td></tr></table></figure>
<h3 id="在第二层高光叠加的时候"><a href="#在第二层高光叠加的时候" class="headerlink" title="在第二层高光叠加的时候"></a>在第二层高光叠加的时候</h3><p>再乘上一层shift_col当噪声</p>
<p><img src="https://img-blog.csdnimg.cn/f04cd43ef2c1432c8f369753e9d45ff8.png" alt="在这里插入图片描述"></p>
<h3 id="Hair-shader"><a href="#Hair-shader" class="headerlink" title="Hair.shader"></a>Hair.shader</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Upgrade <span class="doctag">NOTE:</span> replaced &#x27;_Object2World&#x27; with &#x27;unity_ObjectToWorld&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// Upgrade <span class="doctag">NOTE:</span> replaced &#x27;mul(UNITY_MATRIX_MVP,*)&#x27; with &#x27;UnityObjectToClipPos(*)&#x27;</span></span><br><span class="line"></span><br><span class="line">Shader <span class="string">&quot;Character/Hair&quot;</span></span><br><span class="line">&#123;</span><br><span class="line">    Properties</span><br><span class="line">    &#123;</span><br><span class="line">        _MainTex (<span class="string">&quot;MainTex&quot;</span>, <span class="number">2</span>D) = <span class="string">&quot;white&quot;</span> &#123;&#125;</span><br><span class="line">        _Normal(<span class="string">&quot;Normal&quot;</span>,<span class="number">2</span>D) = <span class="string">&quot;bump&quot;</span> &#123;&#125;</span><br><span class="line">        _DiffuseRamp (<span class="string">&quot;DiffuseRamp&quot;</span>, <span class="number">2</span>D) = <span class="string">&quot;Black&quot;</span> &#123;&#125;</span><br><span class="line">        _Envmap (<span class="string">&quot;Envmap&quot;</span>, Cube) = <span class="string">&quot;Black&quot;</span> &#123;&#125;</span><br><span class="line">        _ShiftRamp(<span class="string">&quot;ShiftRamp&quot;</span>,<span class="number">2</span>D)=<span class="string">&quot;Black&quot;</span>&#123;&#125;</span><br><span class="line"></span><br><span class="line">        [<span class="built_in">Header</span>(Tint Base)]</span><br><span class="line">        _TintBase (<span class="string">&quot;Tint Base&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer1)]</span><br><span class="line">        _RampLayerOffset1 (<span class="string">&quot;RampLayerOffset1&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _TintLayer1 (<span class="string">&quot;Tint_Layer1&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer2)]</span><br><span class="line">        _RampLayerOffset2 (<span class="string">&quot;RampLayerOffset2&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RampLayerSoftness2 (<span class="string">&quot;RampLayerSoftness2&quot;</span>, <span class="built_in">Range</span>(<span class="number">0</span>,<span class="number">1</span>)) = <span class="number">0.5</span></span><br><span class="line">        __TintLayer2 (<span class="string">&quot;Tint Layer2&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(RampLayer3)]</span><br><span class="line">        _RampLayerOffset3 (<span class="string">&quot;RampLayerOffset3&quot;</span>, <span class="built_in">Range</span>(<span class="number">-0.5</span>,<span class="number">0.5</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RampLayerSoftness3 (<span class="string">&quot;RampLayerSoftness3&quot;</span>, <span class="built_in">Range</span>(<span class="number">0</span>,<span class="number">1</span>)) = <span class="number">0.5</span></span><br><span class="line">        __TintLayer3 (<span class="string">&quot;Tint Layer3&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">        [<span class="built_in">Header</span>(Specular1)]</span><br><span class="line">         _SpecularColor1 (<span class="string">&quot;Specular Color1&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">         _SpecularIntensity1 (<span class="string">&quot;SpecularIntensity1&quot;</span>, Float) = <span class="number">1</span></span><br><span class="line">         _SpecularSmooth1 (<span class="string">&quot;Specular Smooth1&quot;</span>,  <span class="built_in">Range</span>(<span class="number">0</span>,<span class="number">1</span>)) = <span class="number">1</span></span><br><span class="line">         _ShiftOffset1 (<span class="string">&quot;Shift Offset1&quot;</span>, Float) = <span class="number">0</span></span><br><span class="line">         [<span class="built_in">Header</span>(Specular2)]</span><br><span class="line">         _SpecularColor2 (<span class="string">&quot;Specular Color2&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">         _SpecularIntensity2 (<span class="string">&quot;SpecularIntensity2&quot;</span>, Float) = <span class="number">1</span></span><br><span class="line">         _SpecularSmooth2 (<span class="string">&quot;Specular Smooth2&quot;</span>, <span class="built_in">Range</span>(<span class="number">0</span>,<span class="number">1</span>)) = <span class="number">1</span></span><br><span class="line">         _ShiftOffset2 (<span class="string">&quot;Shift Offset2&quot;</span>, Float) = <span class="number">0</span> </span><br><span class="line">         </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        [<span class="built_in">Header</span>(Rim)]</span><br><span class="line">        _RimMin(<span class="string">&quot;RimMin&quot;</span>, <span class="built_in">Range</span>(<span class="number">-2</span>,<span class="number">2</span>)) = <span class="number">0.5</span></span><br><span class="line">        _RimMax(<span class="string">&quot;RimMax&quot;</span>, <span class="built_in">Range</span>(<span class="number">-2</span>,<span class="number">2</span>)) = <span class="number">0.5</span></span><br><span class="line">        _Roughness(<span class="string">&quot;Roughness&quot;</span>, Float) = <span class="number">0</span></span><br><span class="line">        _EnvIntensity(<span class="string">&quot;Env Intensity&quot;</span>, Float) = <span class="number">0</span></span><br><span class="line"></span><br><span class="line">        [<span class="built_in">Header</span>(Outline)]</span><br><span class="line">        _Outline (<span class="string">&quot;Outline&quot;</span>, Float) = <span class="number">0.6</span></span><br><span class="line">        _OutlineColor (<span class="string">&quot;OutlineColor&quot;</span>, COLOR) = (<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line">    &#125;</span><br><span class="line">    SubShader</span><br><span class="line">    &#123;</span><br><span class="line">        Tags &#123; <span class="string">&quot;RenderType&quot;</span>=<span class="string">&quot;Opaque&quot;</span> &#125;</span><br><span class="line">        LOD <span class="number">100</span></span><br><span class="line">        </span><br><span class="line">        Pass</span><br><span class="line">        &#123;</span><br><span class="line">            Name <span class="string">&quot;Skin&quot;</span></span><br><span class="line">            Tags &#123; <span class="string">&quot;LightMode&quot;</span> = <span class="string">&quot;ForwardBase&quot;</span> &#125;</span><br><span class="line">            </span><br><span class="line">            Stencil &#123;</span><br><span class="line">                 Ref <span class="number">1</span></span><br><span class="line">                 Comp NotEqual</span><br><span class="line">                 Pass Keep</span><br><span class="line">                 Fail Keep</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            CGPROGRAM</span><br><span class="line">            </span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> vertex vert</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> fragment frag</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> multi_compile_fwdbase</span></span><br><span class="line">            <span class="comment">// make fog work</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> multi_compile_fog</span></span><br><span class="line">            <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;AutoLight.cginc&quot;</span></span></span><br><span class="line">            <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;UnityCG.cginc&quot;</span></span></span><br><span class="line"></span><br><span class="line">            <span class="keyword">struct</span> appdata</span><br><span class="line">            &#123;</span><br><span class="line">                float4 vertex : POSITION;</span><br><span class="line">                float2 texcoord0 : TEXCOORD0;</span><br><span class="line">                float4 normal :NORMAL;</span><br><span class="line">                float4 tangent:TANGENT;</span><br><span class="line">                float4 VertexColor:COLOR;</span><br><span class="line">            &#125;;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">struct</span> <span class="title class_">v2f</span></span><br><span class="line">            &#123;</span><br><span class="line">                </span><br><span class="line">                float4 pos : SV_POSITION;</span><br><span class="line">                float2 uv : TEXCOORD0;</span><br><span class="line"></span><br><span class="line">                float3 normalDir: TEXCOORD1;</span><br><span class="line">                float3 tangentDir: TEXCOORD2;</span><br><span class="line">                float3 binormalDir: TEXCOORD3;</span><br><span class="line">                float4 VertexColor: TEXCOORD4;</span><br><span class="line">                float3 pos_world: TEXCOORD5;</span><br><span class="line">                <span class="built_in">LIGHTING_COORDS</span>(<span class="number">6</span>,<span class="number">7</span>)</span><br><span class="line">            &#125;;</span><br><span class="line"></span><br><span class="line">            sampler2D _MainTex;</span><br><span class="line">            sampler2D _Normal;</span><br><span class="line">            sampler2D _DiffuseRamp;</span><br><span class="line">            samplerCUBE _Envmap;</span><br><span class="line">            sampler2D _ShiftRamp;</span><br><span class="line">            float4 _ShiftRamp_ST;</span><br><span class="line"></span><br><span class="line">            float4 _LightColor0;</span><br><span class="line"></span><br><span class="line">            float4 _MainTex_ST;</span><br><span class="line">            float4 _TintBase;</span><br><span class="line">            float4 __TintLayer1;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset1;</span><br><span class="line"></span><br><span class="line">            float4 __TintLayer2;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset2;</span><br><span class="line">            <span class="type">float</span> _RampLayerSoftness2;</span><br><span class="line">            </span><br><span class="line">            float4 __TintLayer3;</span><br><span class="line">            <span class="type">float</span> _RampLayerOffset3;</span><br><span class="line">            <span class="type">float</span> _RampLayerSoftness3;</span><br><span class="line"></span><br><span class="line">            </span><br><span class="line">            <span class="type">float</span> _ShiftOffset1;</span><br><span class="line">            <span class="type">float</span> _SpecularIntensity1;</span><br><span class="line">            float4 _SpecularColor1;</span><br><span class="line">            <span class="type">float</span> _SpecularSmooth1;</span><br><span class="line">            </span><br><span class="line">            <span class="type">float</span> _ShiftOffset2;</span><br><span class="line">            <span class="type">float</span> _SpecularIntensity2;</span><br><span class="line">            float4 _SpecularColor2;</span><br><span class="line">            <span class="type">float</span> _SpecularSmooth2;</span><br><span class="line"></span><br><span class="line">            <span class="type">float</span> _RimMax;</span><br><span class="line">            <span class="type">float</span> _RimMin;</span><br><span class="line">            <span class="type">float</span> _Roughness;</span><br><span class="line">            <span class="type">float</span> _EnvIntensity;</span><br><span class="line">            float4 _Envmap_HDR;</span><br><span class="line"></span><br><span class="line">            <span class="function">v2f <span class="title">vert</span> <span class="params">(appdata v)</span></span></span><br><span class="line"><span class="function">            </span>&#123;</span><br><span class="line">                v2f o;</span><br><span class="line">                o.pos = <span class="built_in">UnityObjectToClipPos</span>(v.vertex);</span><br><span class="line">                o.uv = v.texcoord0;</span><br><span class="line">                o.normalDir=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.normal).xyz);</span><br><span class="line">                o.tangentDir=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.tangent).xyz);</span><br><span class="line">                o.pos_world=<span class="built_in">normalize</span>( <span class="built_in">mul</span>(unity_ObjectToWorld,v.vertex).xyz);</span><br><span class="line">                o.binormalDir=<span class="built_in">normalize</span>( <span class="built_in">cross</span>(o.normalDir,o.tangentDir)*v.tangent.w);</span><br><span class="line">                o.VertexColor = v.VertexColor;</span><br><span class="line">                <span class="built_in">TRANSFER_VERTEX_TO_FRAGMENT</span>(o);</span><br><span class="line">                <span class="keyword">return</span> o;   </span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            </span><br><span class="line">            <span class="function">half <span class="title">StrandSpecular</span><span class="params">(half3 T, half3 V, half3 L, half exponent)</span></span></span><br><span class="line"><span class="function">            </span>&#123;</span><br><span class="line">                 half3 H = <span class="built_in">normalize</span>(L + V);</span><br><span class="line">                 half dotTH = <span class="built_in">dot</span>(T, H);</span><br><span class="line">                 half sinTH = <span class="built_in">sqrt</span>(<span class="number">1</span> - dotTH * dotTH);</span><br><span class="line">                 half dirAtten = <span class="built_in">smoothstep</span>(<span class="number">-1.0</span>, <span class="number">0.0</span>, dotTH);</span><br><span class="line">                 <span class="keyword">return</span> dirAtten * <span class="built_in">pow</span>(sinTH, exponent);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="function">half4 <span class="title">frag</span> <span class="params">(v2f i)</span> : SV_Target</span></span><br><span class="line"><span class="function">            &#123;</span></span><br><span class="line">                <span class="comment">// sample the texture</span></span><br><span class="line">                half atten = <span class="built_in">LIGHT_ATTENUATION</span> (i);</span><br><span class="line">                half3 base_col = <span class="built_in">tex2D</span>(_MainTex, i.uv).xyz;</span><br><span class="line">                half3 normal_world = <span class="built_in">normalize</span>(i.normalDir);</span><br><span class="line">                half3 tangent_world= <span class="built_in">normalize</span>(i.tangentDir);</span><br><span class="line">                half3 binormal_world= <span class="built_in">normalize</span>(i.binormalDir);</span><br><span class="line">               </span><br><span class="line">                half3 normal_data = <span class="built_in">UnpackNormal</span>(<span class="built_in">tex2D</span>(_Normal,i.uv));</span><br><span class="line">                half3x3 TBN = <span class="built_in">half3x3</span> (tangent_world,binormal_world,normal_world);</span><br><span class="line">                </span><br><span class="line">                normal_world = <span class="built_in">mul</span>(normal_data,TBN);</span><br><span class="line">                half3 ViewDir = <span class="built_in">normalize</span>(_WorldSpaceCameraPos.xyz-i.pos_world);</span><br><span class="line">                half3 lightDir = <span class="built_in">normalize</span>(_WorldSpaceLightPos0.xyz);</span><br><span class="line">                <span class="comment">//漫反射</span></span><br><span class="line">                half NdotL =  <span class="built_in">max</span>(<span class="number">0</span>,<span class="built_in">dot</span>(normal_world,lightDir));</span><br><span class="line">                half half_lambert = (NdotL+<span class="number">1.0</span>)*<span class="number">0.5</span>;</span><br><span class="line">                <span class="comment">//half half_lambert = half_lambert*ao //本来要乘上AO因为素材没有算了</span></span><br><span class="line"></span><br><span class="line">                half3 tint_Base_color1 = base_col;</span><br><span class="line"></span><br><span class="line">                <span class="comment">//第一层ramp</span></span><br><span class="line">                half2 uv_ramp1 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset1,<span class="number">0.5</span>);</span><br><span class="line">                half toon_diffuse1 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp1).r;</span><br><span class="line">                half3 tint_color1 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer1,toon_diffuse1*__TintLayer1.a);</span><br><span class="line">                </span><br><span class="line">                <span class="comment">//第二层ramp</span></span><br><span class="line">                half2 uv_ramp2 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset2,<span class="number">1</span>-i.VertexColor.g+_RampLayerSoftness2);<span class="comment">//1-i.VertexColor.g可以用_RampLayerSoftness2代替越大越柔和</span></span><br><span class="line">                half toon_diffuse2 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp2).g;</span><br><span class="line">                half3 tint_color2 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer2,toon_diffuse2*__TintLayer2.a);</span><br><span class="line">                </span><br><span class="line">                <span class="comment">//第三层ramp</span></span><br><span class="line">                half2 uv_ramp3 = <span class="built_in">half2</span>(half_lambert+_RampLayerOffset3,<span class="number">1</span>-i.VertexColor.b+_RampLayerSoftness3);<span class="comment">//1-i.VertexColor.b可以用_RampLayerSoftness3代替越大越柔和</span></span><br><span class="line">                half toon_diffuse3 = <span class="built_in">tex2D</span>(_DiffuseRamp,uv_ramp3).b;</span><br><span class="line">                half3 tint_color3 = <span class="built_in">lerp</span>(<span class="built_in">half3</span>(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),__TintLayer3,toon_diffuse3*__TintLayer3.a);</span><br><span class="line">                </span><br><span class="line">                half3 final_diffuse = tint_Base_color1 * tint_color1 *tint_color2 *tint_color3  ;</span><br><span class="line">                <span class="comment">//各向异性高光</span></span><br><span class="line">                half2 uv_shift = i.uv * _ShiftRamp_ST.xy + _ShiftRamp_ST.zw;</span><br><span class="line">                half3 shift_col = <span class="built_in">tex2D</span>(_ShiftRamp,uv_shift);</span><br><span class="line">                half3 binormal_world1 = <span class="built_in">normalize</span>( binormal_world + (shift_col+_ShiftOffset1)* normal_world);</span><br><span class="line">                half3 binormal_world2 = <span class="built_in">normalize</span>( binormal_world + (shift_col+_ShiftOffset2)* normal_world);</span><br><span class="line">                half NdotV = <span class="built_in">max</span>(<span class="number">0.00001</span> ,<span class="built_in">dot</span>(normal_world , ViewDir));</span><br><span class="line">                half3 H = <span class="built_in">normalize</span>(lightDir+ViewDir);</span><br><span class="line">                half NdotH = <span class="built_in">dot</span>(normal_world ,H );</span><br><span class="line">                half TdotH = <span class="built_in">dot</span>(tangent_world ,H);</span><br><span class="line">               </span><br><span class="line">              </span><br><span class="line">                half BdotH1 =<span class="built_in">dot</span>(binormal_world1 ,H)/_SpecularSmooth1;</span><br><span class="line">                half spec_term1 =<span class="built_in">exp</span>(-(TdotH*TdotH+BdotH1*BdotH1)/(<span class="number">1.0</span>+NdotH));</span><br><span class="line">                half spec_atten1 = <span class="built_in">saturate</span>(<span class="built_in">sqrt</span>(<span class="built_in">max</span>(<span class="number">0.0</span>,half_lambert/NdotV)));</span><br><span class="line">                half3 specular_col1 = spec_term1* spec_atten1 * _LightColor0.xyz * _SpecularIntensity1 * atten * _SpecularColor1.xyz;</span><br><span class="line">                </span><br><span class="line">                half BdotH2 =<span class="built_in">dot</span>(binormal_world2 ,H)/_SpecularSmooth2;</span><br><span class="line">                half spec_term2 =<span class="built_in">exp</span>(-(TdotH*TdotH+BdotH2*BdotH2)/(<span class="number">1.0</span>+NdotH));</span><br><span class="line">                half spec_atten2 = <span class="built_in">saturate</span>(<span class="built_in">sqrt</span>(<span class="built_in">max</span>(<span class="number">0.0</span>,half_lambert/NdotV)));</span><br><span class="line">                half3 specular_col2 = spec_term2* spec_atten2 * _LightColor0.xyz * _SpecularIntensity2 * atten *_SpecularColor1.xyz*shift_col;</span><br><span class="line"></span><br><span class="line">                 half3 final_specular =   specular_col1 + specular_col2 ;</span><br><span class="line"></span><br><span class="line">                <span class="comment">//half3 half_R = normalize(lightDir+ViewDir);</span></span><br><span class="line">                <span class="comment">//half3 R = normalize(reflect(-lightDir,normal_world));</span></span><br><span class="line">                <span class="comment">//half specular_term = max(pow(dot(R,ViewDir),_Shineness),0.0001);//本来要乘上AO因为素材没有算了</span></span><br><span class="line">                <span class="comment">//specular_term = smoothstep(0.5-_SpecularSmooth*0.5,0.5+_SpecularSmooth*0.5,specular_term);//风格化高光</span></span><br><span class="line">            </span><br><span class="line">                <span class="comment">//half3 final_specular = base_col  * specular_term *_SpecularColor *atten *_LightColor0.xyz *_SpecularIntensity  ;</span></span><br><span class="line">                </span><br><span class="line">                <span class="comment">//边缘光,环境光</span></span><br><span class="line">                half NDL = NdotL&gt;<span class="number">0</span> ? <span class="number">1</span>:<span class="number">0</span>;</span><br><span class="line">                half fresnel = <span class="number">1</span>- <span class="built_in">dot</span>(ViewDir,normal_world);</span><br><span class="line">                half rim = <span class="built_in">smoothstep</span>(_RimMin,_RimMax,fresnel);<span class="comment">//本来要乘上AO因为素材没有算了</span></span><br><span class="line">                rim = rim * NDL;</span><br><span class="line"></span><br><span class="line">                half3 r = <span class="built_in">reflect</span>(-ViewDir,normal_world);</span><br><span class="line">                half roughness = <span class="built_in">lerp</span>(<span class="number">0</span>,<span class="number">0.95</span>,<span class="built_in">saturate</span>(_Roughness));</span><br><span class="line">                roughness = roughness * (<span class="number">1.7</span><span class="number">-0.7</span>*roughness );</span><br><span class="line">                half mip_level = roughness * <span class="number">6.0</span>;</span><br><span class="line">                half4 color_cubemap = <span class="built_in">texCUBElod</span>(_Envmap,<span class="built_in">half4</span>(r,mip_level));</span><br><span class="line">                half3 color_env = <span class="built_in">DecodeHDR</span>(color_cubemap,_Envmap_HDR);</span><br><span class="line">                half3 final_env =color_env * rim * _EnvIntensity    ;</span><br><span class="line"></span><br><span class="line">                half3 final_col = final_diffuse +final_specular +final_env;</span><br><span class="line">                <span class="keyword">return</span> <span class="built_in">half4</span>(final_col,<span class="number">1</span>);</span><br><span class="line">                </span><br><span class="line">            &#125;</span><br><span class="line">            ENDCG</span><br><span class="line">        &#125;</span><br><span class="line">        Pass</span><br><span class="line">        &#123;</span><br><span class="line">        Name <span class="string">&quot;OUTLINE&quot;</span></span><br><span class="line">        Cull Front</span><br><span class="line">    ZWrite On</span><br><span class="line">    ColorMask RGB</span><br><span class="line">    Blend SrcAlpha OneMinusSrcAlpha</span><br><span class="line">            CGPROGRAM</span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> vertex vert</span></span><br><span class="line">            <span class="meta">#<span class="keyword">pragma</span> fragment frag</span></span><br><span class="line">            <span class="meta">#<span class="keyword">include</span> <span class="string">&quot;UnityCG.cginc&quot;</span></span></span><br><span class="line">            <span class="keyword">struct</span> <span class="title class_">appdata</span> &#123;</span><br><span class="line">            float4 vertex : POSITION;</span><br><span class="line">            float3 normal : NORMAL;</span><br><span class="line">            float4 texCoord : TEXCOORD0;</span><br><span class="line">            float4 vertexColor : COLOR;</span><br><span class="line">          &#125;;</span><br><span class="line">          <span class="keyword">struct</span> <span class="title class_">v2f</span> &#123;</span><br><span class="line">          	float4 pos : POSITION;</span><br><span class="line">          	float4 color : COLOR;</span><br><span class="line">          	float4 tex : TEXCOORD0;</span><br><span class="line">          &#125;;</span><br><span class="line">            sampler2D _MainTex;</span><br><span class="line">            <span class="type">float</span> _Outline;</span><br><span class="line">            float4 _OutlineColor;</span><br><span class="line">            <span class="function">v2f <span class="title">vert</span><span class="params">(appdata v)</span> </span>&#123;</span><br><span class="line">            <span class="comment">// just make a copy of incoming vertex data but scaled according to normal direction</span></span><br><span class="line">          	v2f o;</span><br><span class="line">          	o.pos = <span class="built_in">UnityObjectToClipPos</span>(v.vertex);</span><br><span class="line">            float3 norm = <span class="built_in">mul</span>((float3x3)UNITY_MATRIX_IT_MV, v.normal);</span><br><span class="line">            float2 offset = <span class="built_in">TransformViewToProjection</span>(norm.xy);</span><br><span class="line">           <span class="comment">// float2 offset = (norm.xy);</span></span><br><span class="line">          	o.pos.xy += offset * _Outline*<span class="number">0.0001</span>;</span><br><span class="line">          	o.tex = v.texCoord;</span><br><span class="line">          	o.color = v.vertexColor;</span><br><span class="line">          	<span class="keyword">return</span> o;</span><br><span class="line">          &#125;</span><br><span class="line">            <span class="function">fixed4 <span class="title">frag</span> <span class="params">(v2f i)</span> : SV_Target</span></span><br><span class="line"><span class="function">            &#123;</span></span><br><span class="line">                half4 base_col = <span class="built_in">tex2D</span>(_MainTex,i.tex);</span><br><span class="line">                <span class="keyword">return</span> _OutlineColor*base_col;</span><br><span class="line">            &#125;</span><br><span class="line">            ENDCG</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    FallBack <span class="string">&quot;Diffuse&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="脸部"><a href="#脸部" class="headerlink" title="脸部"></a>脸部</h2><p>在皮肤的基础上提亮一点。</p>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls" data-autoplay="false">
                <source type="audio/mpeg" src="/music/jucilang.mp3">
            </audio>
            
        </div>
        
    <div id='gitalk-container' class="comment link"
		data-enable='true'
        data-ae='true'
        data-ci='99f95a936c6fcdb1bd67'
        data-cs='c2d1bba3d6b7f9ade4f3de09a63925bd837c25ea'
        data-r='mrchenlearnspace.github.io'
        data-o='MrChenLearnSpace'
        data-a='MrChenLearnSpace'
        data-d='false'
    >查看评论</div>


    </div>
    
        <div class='side'>
			<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%8F%8F%E8%BE%B9"><span class="toc-number">1.</span> <span class="toc-text">描边</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B3%95%E7%BA%BF%E5%A4%96%E6%89%A9%E6%B3%95"><span class="toc-number">1.1.</span> <span class="toc-text">法线外扩法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A7%A3%E5%86%B3%E6%96%B9%E5%BC%8F"><span class="toc-number">1.1.1.</span> <span class="toc-text">解决方式</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BC%BA%E7%82%B9"><span class="toc-number">1.1.2.</span> <span class="toc-text">缺点</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%8F%B2%E6%B6%85%E5%B0%94%E6%96%B9%E7%A8%8B"><span class="toc-number">1.2.</span> <span class="toc-text">菲涅尔方程</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95"><span class="toc-number">1.2.1.</span> <span class="toc-text">解决方法</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%97%AE%E9%A2%98"><span class="toc-number">1.2.2.</span> <span class="toc-text">问题</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A1%B6%E7%82%B9%E7%9D%80%E8%89%B2%E5%99%A8"><span class="toc-number">1.3.</span> <span class="toc-text">顶点着色器</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95-1"><span class="toc-number">1.3.1.</span> <span class="toc-text">解决方法</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%97%AE%E9%A2%98-1"><span class="toc-number">1.3.2.</span> <span class="toc-text">问题</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9F%BA%E4%BA%8E%E5%9B%BE%E5%83%8F%E7%A9%BA%E9%97%B4%E7%9A%84%E7%BA%BF%E6%9D%A1%E6%A3%80%E6%B5%8B"><span class="toc-number">1.4.</span> <span class="toc-text">基于图像空间的线条检测</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AF%B9%E4%BA%8E%E5%90%8E%E5%A4%84%E7%90%86%E8%BF%9B%E8%A1%8Ccanny%E5%8D%B7%E7%A7%AF"><span class="toc-number">1.5.</span> <span class="toc-text">对于后处理进行canny卷积</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%89%93%E5%85%89"><span class="toc-number">2.</span> <span class="toc-text">打光</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9A%AE%E8%82%A4%E5%92%8C%E8%A1%A3%E6%9C%8D%E9%83%A8%E5%88%86"><span class="toc-number">2.1.</span> <span class="toc-text">皮肤和衣服部分</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%A4%9A%E9%80%9A%E9%81%93Ramp%E7%9A%84shading%E6%96%B9%E6%B3%95"><span class="toc-number">2.1.1.</span> <span class="toc-text">多通道Ramp的shading方法</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%A7%A3%E9%87%8A"><span class="toc-number">2.1.1.1.</span> <span class="toc-text">解释</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81"><span class="toc-number">2.1.1.2.</span> <span class="toc-text">代码</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8D%96%E5%AE%B6%E7%A7%80"><span class="toc-number">2.1.2.</span> <span class="toc-text">卖家秀</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B9%B0%E5%AE%B6%E7%A7%80"><span class="toc-number">2.1.3.</span> <span class="toc-text">买家秀</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BE%B9%E7%BC%98%E5%85%89%EF%BC%8C%E7%8E%AF%E5%A2%83%E5%85%89"><span class="toc-number">2.1.4.</span> <span class="toc-text">边缘光，环境光</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%A7%A3%E9%87%8A-1"><span class="toc-number">2.1.4.1.</span> <span class="toc-text">解释</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0"><span class="toc-number">2.1.4.2.</span> <span class="toc-text">实现</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%80%BB%E4%BD%93%E4%BB%A3%E7%A0%81"><span class="toc-number">2.1.5.</span> <span class="toc-text">总体代码</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9C%BC%E7%9D%9B"><span class="toc-number">2.2.</span> <span class="toc-text">眼睛</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B3%E4%BA%8E%E5%A4%B4%E5%8F%91%E9%81%AE%E6%8C%A1%E7%9C%BC%E7%9D%9B%EF%BC%8C%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95"><span class="toc-number">2.2.1.</span> <span class="toc-text">关于头发遮挡眼睛，解决办法</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%A8%A1%E6%9D%BF%E6%B5%8B%E8%AF%95"><span class="toc-number">2.2.1.1.</span> <span class="toc-text">模板测试</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%B0%86%E9%81%AE%E6%8C%A1%E8%84%B8%E9%83%A8%E9%80%8F%E6%98%8E%E9%83%A8%E5%88%86%E5%86%99%E5%85%A5%E9%A1%B6%E7%82%B9%E8%89%B2A%E9%80%9A%E9%81%93"><span class="toc-number">2.2.1.2.</span> <span class="toc-text">将遮挡脸部透明部分写入顶点色A通道</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Eye-shader"><span class="toc-number">2.2.2.</span> <span class="toc-text">Eye.shader</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A4%B4%E5%8F%91"><span class="toc-number">2.3.</span> <span class="toc-text">头发</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8shiftmap%E5%A2%9E%E5%BC%BA%E8%B4%A8%E6%84%9F"><span class="toc-number">2.3.1.</span> <span class="toc-text">使用shiftmap增强质感</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9D%E7%89%88"><span class="toc-number">2.3.2.</span> <span class="toc-text">初版</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%94%B9%E8%BF%9B"><span class="toc-number">2.3.3.</span> <span class="toc-text">改进</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9C%A8%E7%AC%AC%E4%BA%8C%E5%B1%82%E9%AB%98%E5%85%89%E5%8F%A0%E5%8A%A0%E7%9A%84%E6%97%B6%E5%80%99"><span class="toc-number">2.3.4.</span> <span class="toc-text">在第二层高光叠加的时候</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Hair-shader"><span class="toc-number">2.3.5.</span> <span class="toc-text">Hair.shader</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%84%B8%E9%83%A8"><span class="toc-number">2.4.</span> <span class="toc-text">脸部</span></a></li></ol></li></ol>	
        </div>
    
</div>


    </div>
</div>
</body>

<script src="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>


<script src="//lib.baomitu.com/jquery/1.8.3/jquery.min.js"></script>
<script src="/blog/js/plugin.js"></script>
<script src="/blog/js/typed.js"></script>
<script src="/blog/js/diaspora.js"></script>


<link rel="stylesheet" href="/blog/photoswipe/photoswipe.css">
<link rel="stylesheet" href="/blog/photoswipe/default-skin/default-skin.css">


<script src="/blog/photoswipe/photoswipe.min.js"></script>
<script src="/blog/photoswipe/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>



<script type="text/x-mathjax-config">
    MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) },
        tex2jax: { inlineMath: [ ["$", "$"], ["\\(","\\)"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno",skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']},
        TeX: {  noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } }, Macros: { href: "{}" } },
        messageStyle: "none"
    });
</script>
<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>



<!-- Google Analytics -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YMJ8CBH8F7"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-YMJ8CBH8F7');
</script>
<!-- End Google Analytics -->


</html>
